import {
  prop_cur_req_time,
  prop_cur_req_user_identity,
} from '../../../../../../../../Classes/cla_req_cur_headers_info';
import { req_info_cur_user_function_create } from '../../Classes/cla_req_info_cur_user_function_create';
import {
  get_file_path_cur_user_function,
  get_file_path_cur_user_function_time,
} from './Func/get_file_path_cur_user_function';

import fs from 'fs-extra';

/**
 * 写录  创建 函数 主体文件
 * @param cur_req_info
 */
export function set_file_functions_create(
  cur_req_info: req_info_cur_user_function_create
) {
  let file_path = get_file_path_cur_user_function(
    cur_req_info[prop_cur_req_user_identity],
    cur_req_info.id
  );

  let file_path_time = get_file_path_cur_user_function_time(
    cur_req_info[prop_cur_req_time],
    cur_req_info[prop_cur_req_user_identity],
    cur_req_info.id
  );

  fs.outputFile(file_path, cur_req_info.function);

  fs.outputFile(file_path_time, cur_req_info.function);
}
